package com.lanou.service;/*
 * @author 马继耿~
 * @date 2023/10/25 17:22
 * @version 1.0
 * */

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.mapper.MJG_ProvisionalMapper;
import com.lanou.pojo.PaymentDepositEntity;
import com.lanou.pojo.PaymentTempEntity;
import com.lanou.service.MJG_ProvisionalService;
import com.lanou.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MJG_ProvisionalServiceImpl implements MJG_ProvisionalService {
    @Autowired
    private MJG_ProvisionalMapper mjg_provisionalMapper;
    @Override
    public JsonResult Provisional(String resourceName) {
        List<PaymentTempEntity> provisional = mjg_provisionalMapper.Provisional(resourceName);
        PageInfo<PaymentTempEntity> paymentTempEntityPageInfo = new PageInfo<>(provisional);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(paymentTempEntityPageInfo);
        jsonResult.setStatus(200);

        return jsonResult;
    }

    @Override
    public JsonResult Provisional(String pageNum, String pageSize) {
        //处理分页查询
        if(pageNum == null || "".equals(pageNum)){
            pageNum="1";
        }
        if(pageSize == null || "".equals(pageSize)){
            pageSize="5";
        }
        PageHelper.startPage(Integer.valueOf(pageNum),Integer.valueOf(pageSize));
        List<PaymentTempEntity> provisional = mjg_provisionalMapper.Provisional1();
        PageInfo<PaymentTempEntity> paymentTempEntityPageInfo = new PageInfo<>(provisional);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(paymentTempEntityPageInfo);
        jsonResult.setStatus(200);

        return jsonResult;
    }
    @Override
    public JsonResult select(String resourceName, String feeUser, String state, String feeItemName, String payType) {
        List<PaymentTempEntity> provisional = mjg_provisionalMapper.Provisional2(resourceName,feeUser,state,feeItemName,payType);
        PageInfo<PaymentTempEntity> paymentTempEntityPageInfo = new PageInfo<>(provisional);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(paymentTempEntityPageInfo);
        jsonResult.setStatus(200);
        return jsonResult;
    }

}
